import {DELETE, GET, POST} from "@/api/network";

export module Api {

    export module Stars {

        export interface SearchRequest {
            name: string
        }


        export interface SearchResponseItem {
            star_id: string
            name: string
            nick_name: string
            avatar: string
        }

        export interface SearchResponse {
            items : Array<SearchResponseItem>
        }

        export function Search(ask: SearchRequest) : Promise<SearchResponse> {
            return GET<SearchResponse>(
                `/star/search/${ask.name}`
            )
        }

        /*
        type Ack struct {
		StarID     string `json:"star_id"`
		Name       string `json:"name"`
		NickName   string `json:"nick_name"`
		Avatar     string `json:"avatar"`
		Background string `json:"background"`
		Info       string `json:"info"`
		Enable     bool   `json:"enable"`
	}
         */

        export interface StarInfoRequest {
            star_id : string
        }

        export interface StarInfoResponse {
            star_id: string
            name:string
            nick_name :string
            avatar: string
            background: string
            enable: boolean
            sex:number
        }

        export function GetStarInfo(ask : StarInfoRequest) : Promise<StarInfoResponse> {
            return GET(
                `/star/info/${ask.star_id}`,
            )
        }
        
        
        export interface GetStarClubsRequest {
            star_id: string
            
        }



        export interface GetStarClubsResponse_Item {
            club_id :string
            uid: string
            name: string
            phone: string
            create_time: string
        }
        
        export interface GetStarClubsResponse {
            items : Array<GetStarClubsResponse_Item>
        }

        export function GetStarClubs(ask: GetStarClubsRequest) :Promise<GetStarClubsResponse> {
            return GET(
                `/star/clubs/${ask.star_id}`
            )
        }


        export interface GetSyncClubsRequest {
            star_id: string

        }

        export interface GetSyncClubsResponse_Item {
            club_id:string
            uid: string
            name:string
            phone:string
            idcard_name:string
            user_name:string
            status:string
        }

        export interface GetSyncClubsResponse {
            items: Array<GetSyncClubsResponse_Item>
        }

        export function GetSyncClubs(ask: GetSyncClubsRequest) : Promise<GetSyncClubsResponse> {
            return GET(
                `/stars/sync/clubs/${ask.star_id}`
            )
        }


        export interface GetClubRequest {
            club_id:string
        }

        export interface GetClubResponse {
            club_id:string
            star_id:string
            star_name:string
            star_avatar:string
            uid:string
            user_name:string
            user_avatar:string
            name:string
            phone:string
            idcard_front:string
            idcard_back:string
            idcard_front_addr:string
            idcard_back_addr:string
            idcard_name:string
            enable:boolean
            weibo:string
        }

        export function GetClub(ask:GetClubRequest) : Promise<GetClubResponse> {
            return GET(
                `/club/info/${ask.club_id}`
            )
        }

        export function GetSyncClub(ask:GetClubRequest) : Promise<GetClubResponse> {
            return GET(
                `/stars/club/sync/${ask.club_id}`
            )
        }

        export interface CreateClubResponse {
            club_id:string
        }

        export interface CreateClubRequest {
            club_id:string
            star_id:string
            uid:string
            name:string
            phone:string
            idcard_front:string
            idcard_back:string
            idcard_name:string
            enable:boolean
            weibo:string
        }

        export function CreateClub(ask: CreateClubRequest): Promise<CreateClubResponse> {
            return POST(
                `/stars/club/create`,
                ask,
            )
        }

        export function SetClub(ask: CreateClubRequest) : Promise<CreateClubResponse> {
            return POST(
                `/stars/club/edit`,
                ask,
            )
        }

        export interface RemoveClubManageRequest {
            club_id:string
        }
        
        export interface RemoveClubManageResponse {

        }

        export function RemoveClubManage(ask : RemoveClubManageRequest) : Promise<RemoveClubManageResponse> {
            return DELETE(
                `/stars/club/manage/${ask.club_id}`
            )
        }


        export interface CreateStarRequest {
            name:string
            nick_name:string
            avatar:string
            sex:number
            enable:boolean
            background:string
            describe:string
        }

        export interface CreateStarResponse {
            star_id:string
        }

        export function CreateStar(ask:CreateStarRequest):Promise<CreateStarResponse> {
            return POST(
                `/stars/create`,
                ask,
            )
        }

        export interface SetStarRequest {
            star_id:string
            name:string
            nick_name:string
            avatar:string
            sex:number
            enable:boolean
            background:string
            describe:string
        }

        export interface SetStarResponse {

        }

        export function SetStar(ask:SetStarRequest):Promise<SetStarResponse> {
            return POST(
                `/stars/edit`,
                ask,
            )
        }


        export interface GetClubApplyListRequest {

            page:number
            all:boolean

        }

        export interface GetClubApplyListResponse_Item {

            uid:string
            club_name:string
            club_icon:string
            club_weibo:string
            name:string
            phone:string
            qq:string
            wx:string
            club_id:string
            create_time:string
            status:number
        }

        export interface GetClubApplyListResponse {
            items:Array<GetClubApplyListResponse_Item>
            total:number
        }

        export function GetClubApplyList(ask: GetClubApplyListRequest) : Promise<GetClubApplyListResponse> {
            return GET(
                `/stars/club/apply/list`,
                {
                    query:{
                        page: ask.page,
                        all:ask.all,
                    }
                }
            )
        }
        
        
        export interface GetClubApplyRequest {
            uid:string
        }

        /*
        Status    pb.ClubApplyStatus `json:"status"`
		ClubID    string             `json:"club_id"`
		ClubName  string             `json:"club_name"`
		ClubIcon  string             `json:"club_icon"`
		Name      string             `json:"name"`
		Phone     string             `json:"phone"`
		QQ        string             `json:"qq"`
		WX        string             `json:"wx"`
		ClubWeibo string             `json:"club_weibo"`
		Front     string             `json:"front"`
		Back      string             `json:"back"`
         */

        export interface GetClubApplyResponse {
            status:number
            club_id:string
            club_name:string
            club_icon:string
            name:string
            phone:string
            qq:string
            wx:string
            club_weibo:string
            front:string
            back:string
            real_name:string
            uid:string
            user_name:string
            user_avatar:string
            star_id:string
            front_url:string
            back_url:string
            star_name:string
            star_avatar:string
        }

        export function GetClubApply(ask: GetClubApplyRequest) : Promise<GetClubApplyResponse> {
            return GET(
                `/stars/club/apply/info/${ask.uid}`
            )
        }
        
        export interface RefuseClubApplyRequest {
            uid:string
        }
        
        export interface RefuseClubApplyResponse {

        }

        export function RefuseClubApply(ask: RefuseClubApplyRequest) : Promise<RefuseClubApplyResponse> {
            return POST(
                `/stars/club/apply/refuse`,
                ask,
            )
        }

        /*
type Ask struct {
		Uid       string `json:"uid"`
		ClubID    string `json:"club_id"`
		ClubName  string `json:"club_name"`
		ClubIcon  string `json:"club_icon"`
		ClubWeibo string `json:"club_weibo"`
		RealName  string `json:"real_name"`
		Phone     string `json:"phone"`
		QQ        string `json:"qq"`
		WX        string `json:"wx"`
		Front     string `json:"front"`
		Back      string `json:"back"`
		StarID    string `json:"star_id"`
	}
         */
        export interface SetClubApplyRequest {
            uid:string
            club_id:string
            club_name:string
            club_icon:string
            club_weibo:string
            real_name:string
            phone:string
            qq:string
            wx:string
            front:string
            back:string
            star_id:string
        }

        export interface SetClubApplyResponse {

        }

        export function SetClubApply(ask:SetClubApplyRequest) : Promise<SetClubApplyResponse> {
            return POST(
                `/stars/club/apply/edit`,
                ask,
            )
        }

        /*
        type Item struct {
		StarId   string `json:"star_id"`
		Name     string `json:"name"`
		NickName string `json:"nick_name"`
		Avatar   string `json:"avatar"`
	}

	type Ack struct {
		Items []*Item `json:"items"`
	}
         */
        export interface GetTopStarsResponse_Item {
            star_id:string
            name:string
            avatar:string
        }

        export interface GetTopStarsResponse {
            items:Array<GetTopStarsResponse_Item>
        }

        export interface GetTopStarsRequest  {

        }

        export function GetTopStars(ask:GetTopStarsRequest) : Promise<GetTopStarsResponse> {
            return GET('/stars/tops/search')
        }
    }

}

export default Api.Stars